﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;

namespace Models
{
    [Serializable()]
    public class Participant : ISerializable
    {
        public String FirstName { get; set; }
        public String LastName { get; set; }
        public String Alias { get; set; }
        public String JobTitle { get; set; }
        public String Address { get; set; }
        public String City { get; set; }
        public String State { get; set; }
        public Int32 Zip { get; set; }
        public Int32 Phone { get; set; }

        public Participant()
        {
           FirstName = "";
           LastName = "";
           Alias = "";
           JobTitle = "";
           Address = "";
           City = "";
           State = "";
           Zip = 0;
           Phone = 0;
        }

        public Participant(String firstName, String lastName, String alias, String jobTitle, String address, String city, String state, Int32 zip, Int32 phone)
        {
            this.FirstName = firstName;
            this.LastName = lastName;
            this.Alias = alias;
            this.JobTitle = jobTitle;
            this.Address = address;
            this.City = city;
            this.State = state;
            this.Zip = zip;
            this.Phone = phone;
        }

        #region Serialization

        //Serialization function.
        public void GetObjectData(SerializationInfo info, StreamingContext ctxt)
        {
            info.AddValue("FirstName", this.FirstName);
            info.AddValue("LastName", this.LastName);
            info.AddValue("Alias", this.Alias);
            info.AddValue("JobTitle", this.JobTitle);
            info.AddValue("Address", this.Address);
            info.AddValue("City", this.City);
            info.AddValue("State", this.State);
            info.AddValue("Zip", this.Zip);
            info.AddValue("Phone", this.Phone);

        }

        //Deserialization constructor.
        public Participant(SerializationInfo info, StreamingContext ctxt)
        {
            this.FirstName = (String)info.GetValue("FirstName", typeof(String));
            this.LastName = (String)info.GetValue("LastName", typeof(String));
            this.Alias = (String)info.GetValue("Alias", typeof(String));
            this.JobTitle = (String)info.GetValue("JobTitle", typeof(String));
            this.Address = (String)info.GetValue("Address", typeof(String));
            this.City = (String)info.GetValue("City", typeof(String));
            this.State = (String)info.GetValue("State", typeof(String));
            this.Zip = (Int32)info.GetValue("Zip", typeof(Int32));
            this.Phone = (Int32)info.GetValue("Phone", typeof(Int32));
        }

        #endregion

    }
}
